<script setup lang="ts">
import { onMounted } from 'vue';
import { state } from './state';
import { getCurrentInstance, redirectTo } from '@tarojs/taro';
import { GENERATE_APP_SCHEDULE_RECORD_QR_CODE } from '/@/api/modules/base/schedule-app';
/**
 * 获取路由参数
 */
const params = getCurrentInstance().router?.params as { id: string };
function generateAppScheduleRecordQrCode(id: string) {
  GENERATE_APP_SCHEDULE_RECORD_QR_CODE({ id })
    .then((res) => {
      state.qrCodeUrl = res.qrCodeUrl || '';
    })
    .catch();
}
onMounted(() => {
  generateAppScheduleRecordQrCode(params.id);
});
</script>

<template>
  <view class="app-page--1">
    <app-navbar title="待签收" />
    <scroll-view class="app-page__wrapper" :scroll-y="true" :lower-threshold="100">
      <view class="swap-start-success__wrapper">
        <view><text>请接班人扫码确认交接内容，</text></view>
        <view><text>签收后不可更改！</text></view>
        <view class="swap-start-success__img-container">
          <image class="swap-start-success__img-container__img" :src="state.qrCodeUrl" />
        </view>
      </view>
    </scroll-view>
    <view class="swap-start-success__footer">
      <nut-button
        block
        shape="round"
        type="info"
        @click="
          redirectTo({
            url: `/pages/swap/detail/index?id=${params.id}`,
          })
        "
      >
        详情
      </nut-button>
    </view>
    <view class="swap-start-success__footer">
      <nut-button
        block
        shape="round"
        type="info"
        @click="
          redirectTo({
            url: '/pages/swap/list/index',
          })
        "
      >
        列表
      </nut-button>
    </view>
  </view>
</template>

<style lang="scss">
@import './index.scss';
</style>
